/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 *
 */

import { ConfigSchemaFileConst } from '../../const/common-const.js';
import { AppOhosConfig } from '../../options/build/app-ohos-config.js';
import { HapOhosConfig, HarOhosConfig } from '../../options/build/hap-ohos-config.js';

import { ValidateUtil } from './validate-util.js';
import { ValidatorStore } from './validator-store.js';

/**
 * 校验在hvigorfile.ts里配置的config.ohos字段的内容
 */
export function validateOhosProjectConfig(config: AppOhosConfig, filePath: string) {
  const validator = ValidatorStore.addValidator(ConfigSchemaFileConst.PROJECT_SCHEMA_PATH, false);
  ValidateUtil.schemaCheckJSObject(config, filePath, validator);
}

export function validateOhosModuleConfig(config: HapOhosConfig, filePath: string) {
  const validator = ValidatorStore.addValidator(ConfigSchemaFileConst.MODULE_SCHEMA_PATH, false);
  ValidateUtil.schemaCheckJSObject(config, filePath, validator);
}

export function validateOhosHarModuleConfig(config: HarOhosConfig, filePath: string) {
  const validator = ValidatorStore.addValidator(ConfigSchemaFileConst.HAR_MODULE_SCHEMA_PATH, false);
  ValidateUtil.schemaCheckJSObject(config, filePath, validator);
}
